//
//  DJShopListView.m
//  Adorable_Things
//
//  Created by lanou on 16/1/12.
//  Copyright © 2016年 Banana Inc. All rights reserved.
//

#import "DJShopListView.h"
#import "XLPlainFlowLayout.h"

@implementation DJShopListView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor orangeColor];
        self.contentSize = CGSizeMake(kWidth, kHeight + 210);
        self.bounces = NO;
        self.scrollEnabled = YES;
        self.showsHorizontalScrollIndicator = NO;
        self.showsVerticalScrollIndicator = NO;
        
        self.iconImageV = [[UIImageView alloc]initWithFrame:CGRectMake((kWidth - 50) / 2, 20, 50, 50)];
        self.iconImageV.layer.cornerRadius = 25;
        self.iconImageV.layer.masksToBounds = YES;
        [self addSubview:self.iconImageV];
        
        self.nameLab = [[UILabel alloc]initWithFrame:CGRectMake(0, self.iconImageV.bottom + 10, kWidth , 20)];
        self.nameLab.textAlignment = NSTextAlignmentCenter;
        self.nameLab.textColor = [UIColor whiteColor];
        self.nameLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.nameLab];
        
        self.favoriteLab = [[UILabel alloc]initWithFrame:CGRectMake(0, self.nameLab.bottom + 10, kWidth, 20)];
        self.favoriteLab.textAlignment = NSTextAlignmentCenter;
        self.favoriteLab.textColor = [UIColor whiteColor];
        self.favoriteLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.favoriteLab];
        
        self.introLab = [[UILabel alloc]initWithFrame:CGRectMake(0, self.favoriteLab.bottom , kWidth, 40)];
        self.introLab.textAlignment = NSTextAlignmentCenter;
        self.introLab.textColor = [UIColor whiteColor];
        self.introLab.numberOfLines = 0;
        self.introLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.introLab];
        
        self.attentionButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.attentionButton.frame = CGRectMake(self.iconImageV.left, self.introLab.bottom + 10, 70, 30);
        self.attentionButton.layer.cornerRadius = 15;
        self.attentionButton.layer.masksToBounds = YES;
        self.attentionButton.backgroundColor = [UIColor yellowColor];
        [self.attentionButton setTitleColor:[UIColor orangeColor] forState:(UIControlStateNormal)];
        [self addSubview:self.attentionButton];
        
       // UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        XLPlainFlowLayout *layout = [XLPlainFlowLayout new];
        layout.minimumInteritemSpacing = 10;
        layout.minimumLineSpacing = 10;
        layout.itemSize = CGSizeMake((kWidth - 30) / 2, 250);
        layout.headerReferenceSize = CGSizeMake(kWidth, 30);
        layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        
        self.collectionV = [[UICollectionView alloc]initWithFrame:CGRectMake(0, self.attentionButton.bottom + 10, kWidth, kHeight - 20) collectionViewLayout:layout];
        self.collectionV.backgroundColor = [UIColor whiteColor];
        self.collectionV.showsVerticalScrollIndicator = NO;
        self.layer.masksToBounds = YES;
        [self addSubview:self.collectionV];
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
